import { ApiResult, get, post, fetchPut, fetchDelete } from "@/util/request";
import { loginRequest, loginResponse } from "@/types/apiTypes";

//查询枚举值
export async function resultEn(params?: any): Promise<ApiResult<any>> {
  return await get<any>("/manage/v1/enum/resultEn", params);
}

export async function login(
  params?: loginRequest,
): Promise<ApiResult<loginResponse>> {
  return await post<loginResponse>("/manage/v1/login/login", params);
}

export async function captcha(params?: any): Promise<ApiResult<any>> {
  return await post<any>(`/manage/v1/login/captcha`, params, {
    responseType: "blob",
  });
}

export async function sysRolePage(params?: any): Promise<ApiResult<any>> {
  return await post<any>("/manage/v1/sysRole/page", params);
}

export async function updateRole(params?: any): Promise<ApiResult<any>> {
  return await post<any>("/manage/v1/sysRole/updateRole", params);
}

export async function saveRole(params?: any): Promise<ApiResult<any>> {
  return await post<any>("/manage/v1/sysRole/saveRole", params);
}

export async function selectRole(roleId?: any): Promise<ApiResult<any>> {
  return await get<any>(`/manage/v1/sysRole/select/${roleId}`);
}

export async function deleteRole(roleId?: any): Promise<ApiResult<any>> {
  return await get<any>(`/manage/v1/sysRole/delete/${roleId}`);
}
//用户分页查询
export async function pageSysUser(params?: any): Promise<ApiResult<any>> {
  return await post<any>(`/manage/v1/auth/pageSysUser`, params);
}

export async function selectMenuList(params?: any): Promise<ApiResult<any>> {
  return await get<any>(`/manage/v1/sysMenu/selectMenuList`, params);
}

export async function saveMenu(params?: any): Promise<ApiResult<any>> {
  return await post<any>("/manage/v1/sysMenu/saveMenu", params);
}

export async function updateMenu(params?: any): Promise<ApiResult<any>> {
  return await post<any>("/manage/v1/sysMenu/updateMenu", params);
}

export async function selectSysMenuById(params?: any): Promise<ApiResult<any>> {
  return await get<any>(`/manage/v1/sysMenu/selectSysMenuById`, params);
}

export async function deleteSysMenu(params?: any): Promise<ApiResult<any>> {
  return await get<any>(`/manage/v1/sysMenu/deleteSysMenu`, params);
}

export async function pageSysDict(params?: any): Promise<ApiResult<any>> {
  return await post<any>("/manage/v1/sysDict/pageSysDict", params);
}

export async function selectDict(id?: any): Promise<ApiResult<any>> {
  return await get<any>(`/manage/v1/sysDict/select/${id}`);
}

export async function saveSysDict(params?: any): Promise<ApiResult<any>> {
  return await post<any>("/manage/v1/sysDict/saveSysDict", params);
}

export async function updateSysDict(params?: any): Promise<ApiResult<any>> {
  return await post<any>("/manage/v1/sysDict/updateSysDict", params);
}

export async function deleteDict(params?: any): Promise<ApiResult<any>> {
  return await get<any>(`/manage/v1/sysDict/delete/${params}`);
}

//查询所有字典值
export async function selectDicts(params?: any): Promise<ApiResult<any>> {
  return await get<any>(`/manage/v1/sysDict/selectDicts`, params);
}
//查询字典值两级
export async function selectSysDictDataParentOrChilderById(
  params?: any,
): Promise<ApiResult<any>> {
  return await get<any>(
    `/manage/v1/sysDict/selectSysDictDataParentOrChilderById/${params}`,
  );
}

//  /manage/v1/sysDict/selectSysDictByParentId/{parentId}
export async function selectSysDictByParentId(
  parentId?: any,
): Promise<ApiResult<any>> {
  return await get<any>(
    `/manage/v1/sysDict/selectSysDictByParentId/${parentId}`,
  );
}
//获取字典详情根据code
export async function dict(params?: any): Promise<ApiResult<any>> {
  return await get<any>(`/manage/v1/sysDict/selectDictByCode/${params}`);
}

//审核模版配置
//通过id获取审批模版
export async function selectCastById(params?: any): Promise<ApiResult<any>> {
  return await get<any>(`/manage/v1/castAuditTmpl/${params}`);
}
//模版列表
export async function selectCastList(params?: any): Promise<ApiResult<any>> {
  return await get<any>(`/manage/v1/castAuditTmpl/list`, params);
}
//根据类型获取审批模版
export async function selectCastByType(params?: any): Promise<ApiResult<any>> {
  return await get<any>(`/manage/v1/castAuditTmpl/type`, params);
}
//新增模版
export async function addCast(params?: any): Promise<ApiResult<any>> {
  return await post<any>(`/manage/v1/castAuditTmpl`, params);
}
//编辑模版
export async function updateCast(
  params?: any,
  id?: any,
): Promise<ApiResult<any>> {
  return await fetchPut<any>(`/manage/v1/castAuditTmpl/${id}`, params);
}
//删除模版
export async function delCast(params?: any): Promise<ApiResult<any>> {
  return await fetchDelete<any>(`/manage/v1/castAuditTmpl/${params}`);
}

export async function selectSysRoleList(params?: any): Promise<ApiResult<any>> {
  return await get<any>(`/manage/v1/auth/selectSysRoleList/${params}`);
}

export async function authRoleMenu(params?: any): Promise<ApiResult<any>> {
  return await post<any>(`/manage/v1/auth/authRoleMenu`, params);
}

export async function updatePassword(params?: any): Promise<ApiResult<any>> {
  return await post<any>(`/manage/v1/login/updatePassword`, params);
}

//添加考试配置
export async function saveOrUpdateExamConfig(
  params?: any,
): Promise<ApiResult<any>> {
  return await post<any>(
    `/manage/v1/examConfig/saveOrUpdateExamConfig`,
    params,
  );
}
//查询考试配置
export async function selectExamConfig(params?: any): Promise<ApiResult<any>> {
  return await post<any>(`/manage/v1/examConfig/selectExamConfig`, params);
}
//文件上传
export async function uploadUrl(params?: any): Promise<ApiResult<any>> {
  return await post<any>(`/manage/v1/storage/upload`, params);
}
//统计活跃度
export async function selectActiveTotal(params?: any): Promise<ApiResult<any>> {
  return await post<any>(`/manage/v1/total/selectActiveTotal`, params);
}

//新增题库类型
export async function saveQuestionType(params?: any): Promise<ApiResult<any>> {
  return await post<any>(`/manage/v1/questionType/save`, params);
}
//批量配置题型
export async function updateBatchQuestionType(
  params?: any,
): Promise<ApiResult<any>> {
  return await post<any>(`/manage/v1/questionType/updateBatch`, params);
}
//题型列表
export async function selectListQuestionType(
  params?: any,
): Promise<ApiResult<any>> {
  return await get<any>(`/manage/v1/questionType/selectList`, params);
}
//根据id删除测试类型
export async function delQuestionTypeById(
  params?: any,
): Promise<ApiResult<any>> {
  return await get<any>(`/manage/v1/questionType/delQuestionTypeById`, params);
}
//单挑查询题型
export async function selectQuestionTypeById(
  params?: any,
): Promise<ApiResult<any>> {
  return await get<any>(
    `/manage/v1/questionType/selectQuestionTypeById`,
    params,
  );
}
//查询所有题型
export async function selectQuestionTypes(
  params?: any,
): Promise<ApiResult<any>> {
  return await get<any>(`/manage/v1/questionType/selectQuestionTypes`, params);
}

//审核日志
export async function auditList(
  params?: any,
): Promise<ApiResult<any>> {
  return await post<any>(`/manage/v/wx/pageInfo`, params);
}
